package net.joey.file;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

/**
 * 0-7的字符不是文本字符，所以只有在二进制文件中才有
 * @author gameuser
 *
 */
public class Ch2 {
	private static final String RAGEX = "[0x00-0x07]";

	public static void main(String[] args) throws IOException {
		File file = new File("c:/abc");
		File[] files = file.listFiles();
		for (int i = 0; i < files.length; i++) {
			System.out.println(files[i].getName() + "\t" + getCheck(files[i]));
		}
	}

	public static boolean getCheck(File f) throws IOException {
		BufferedReader br = new BufferedReader(new FileReader(f));
		String temp = "";
		while ((temp = br.readLine()) != null) {
			for (int i = 0; i < temp.length(); i++) {
				if ((temp.charAt(i) + "").matches(RAGEX)) {
					return true;
				}
			}
		}
		br.close();
		return false;
	}
}